//
//  InfoViewController.m
//  Blank
//
//  Created by whg－54 on 15/9/23.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "InfoViewController.h"

#import <UIWebView+AFNetworking.h>

@interface InfoViewController ()<UIWebViewDelegate>

@end

@implementation InfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    NSLog(@"%@",self.urlStr);
    UIButton *buttonBack = [UIButton buttonWithType:UIButtonTypeCustom];
    [buttonBack setImage:[UIImage imageNamed:@"iconfont-fanhui"] forState:UIControlStateNormal];
    buttonBack.frame = CGRectMake(0, 0, 20, 20);
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:buttonBack];
    
    [buttonBack addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
    
    UIWebView *webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
    webView.scalesPageToFit=NO;
    
    webView.scrollView.bounces = NO;
    
    NSString *str = self.urlStr;
    NSLog(@"%@",str);
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:str]];
    
    [webView loadRequest:request];
    
    [self.view addSubview:webView];
    
    webView.delegate = self;
    
}

-(void)webViewDidStartLoad:(UIWebView *)webView
{
    NSLog(@"%f", [UIScreen mainScreen].bounds.size.width);
    if (320 == [UIScreen mainScreen].bounds.size.width) {
    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('P')[7].style.background= 'red'"];
}
    
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    
    if ([NightModel getColorModel]) {
        
        [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextFillColor= 'white'"];
        //页面背景色
        [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.background='gray'"];
    }
    
    
    
    
    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('p')[7].style.font-size= '10px'"];
}

- (void)back:(UIButton *)button
{
    [self.navigationController popViewControllerAnimated:YES];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
